package com.ewili.x.special.service.data.impl;

import com.ewili.framework.utils.ExceptionUtils;
import com.ewili.x.special.service.data.inter.StrategyTestService;
import org.apache.commons.io.FileUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.springframework.stereotype.Service;

import java.io.File;
import java.io.IOException;
import java.util.List;

/**
 * @author wonder
 */
@Service
public class StrategyTestServiceImpl implements StrategyTestService {

    @Override
    public void readTester() {

        String fileContent = null;

        File file = new File("E:\\1.htm");
        try {
            fileContent = FileUtils.readFileToString(file, "utf-8");
        } catch (IOException e) {
            ExceptionUtils.propagate(e);
        }
        Document fileDocument = Jsoup.parse(fileContent);
        Element element = fileDocument.body();
        List<Element> tags = element.getElementsByTag("tr");

        for (int i = 0; i < tags.size(); i++) {
            List<Element> tds = tags.get(i).getElementsByTag("td");
            if (tds.size() != 10) {
                continue;
            }
            String dateStr = tds.get(1).text();
            String typeStr = tds.get(2).text();
            String orderNumStr = tds.get(3).text();
            String lotStr = tds.get(4).text();
            //String  tds.get(5).text();


        }
    }
}
